﻿using System.Collections.Generic;
using System.Data;
using System.Data.SQLite;
using System.Linq;

using Dapper;


using SQLiteDemo.Model;

namespace SQLiteDemo
{
    public class SQLiteTool
    {
        public static string conn = @"Data Source=D:\green\sqlite\zss.db;";

        public static List<Student> GetAllStudents()
        {
            //此处需要特别注意，这个 SQLiteConnection 是 System.Data.SQLite， 不是  Microsoft.Data.Sqlite.SqliteConnection

            using (IDbConnection cnn = new SQLiteConnection(conn))
            {
                cnn.Open();

                var output = cnn.Query<Student>("select * from student").ToList();

                return output.ToList();
            }
        }
    }
}
